package org.jpass.dc.view.upload;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.ProgressListener;

public class MyProgressListener implements ProgressListener {

	private HttpSession session;
    // 上传是否完成  
    private boolean isComplete = false;
    
    public MyProgressListener(HttpServletRequest req) {
    	 session=req.getSession();
    	 UploadStatus status = new UploadStatus();
         session.setAttribute("status", status);
    }
    
    @Override  
    public void update(long bytesRead, long contentLength, int items) {  
    	UploadStatus status = (UploadStatus) session.getAttribute("status");
        status.setCurLength(bytesRead);
        status.setContLength(contentLength);
        status.setItems(items);
    }  
    
    public boolean isComplete() {  
        return isComplete;  
    }  

    /** 
     * the setter method of the isComplete 
     *  
     * @param isComplete 
     *            the isComplete to set 
     */  
    public void setComplete(boolean isComplete) {  
        this.isComplete = isComplete;  
    }
}
